package com.bestv.search.common.dao.hibernate;

import com.bestv.search.common.dao.KeywordDao;
import com.bestv.search.common.model.Keyword;

import java.util.List;

public class KeywordDaoHibernate extends GenericDaoHibernate<Keyword, Long> implements KeywordDao {
    public KeywordDaoHibernate() {
        super(Keyword.class);
    }

    @SuppressWarnings("unchecked")
    @Override
    public Keyword getKeywordByName(String keyword) {
        List<Keyword> list = getHibernateTemplate().find("from Keyword k where k.keyword = ?", keyword);
        if (list == null || list.size() == 0) {
            return null;
        }
        return list.get(0);
    }
}
